package com.zym.init.core.utils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zym.init.mapper.StorageMapper;
import com.zym.init.model.po.StoragePo;

import java.util.List;

/**
 * 数据库配置工具类
 */
public class ConfigUtils {

    /**
     * 获取默认存储配置
     *
     * @return 存储配置
     */
    public static StoragePo getDefaultStorage() {
        StorageMapper mapper = SpringUtils.getBean(StorageMapper.class);
        QueryWrapper<StoragePo> wrapper = new QueryWrapper<>();
        wrapper.eq("is_default", true);
        List<StoragePo> list = mapper.selectList(wrapper);
        if (!list.isEmpty()) {
            return list.get(0);
        }
        return null;
    }

}
